//
//  FollowViewModel.swift
//  SwiftDemo
//
//  Created by 李国卿 on 2020/2/24.
//  Copyright © 2020 guoqing.li. All rights reserved.
//

import UIKit

class FollowViewModel: BaseViewModel {
    
}
extension FollowViewModel{
    func loadFollowData(finishCallBack : @escaping() -> ()) {
        
        NetWorkTools.requestData(type: .get, URLString: "http://capi.douyucdn.cn/api/v1/getbigDataRoom", parameters: ["time":NSDate.getCurrentTime()]){ (result) in
            
            //1.获取字典
            guard let resultDict = result as? [String : Any] else {return}
            //2.获取dataArray
            guard let dataArray = resultDict["data"] as? [[String : Any]] else {return}
            //3.1创建group
            let group = AnchorGroupModel()
            group.tag_name = "直播推荐"
            group.icon_name = "Icon_oranger"
            //3.2遍历dataArray
            for dict in dataArray{
                group.anchors.append(AnchorModel(dic: dict))
            }
            //3.3将gorup添加到anchorGroup中
            self.anchorGroups.append(group)
            
            //4 回调
            finishCallBack()
        }
    }
}
